package com.xiguaji.tiktok.task.ranking;

import com.gugee.tiktok.common.model.dal.blogger.BloggerTypeRepository;
import com.gugee.tiktok.common.model.dal.ranking.RankingRepository;
import com.gugee.tiktok.common.model.mysql.BloggerType;
import com.gugee.tiktok.common.model.ranking.Ranking;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RankingService {

    @Autowired
    RankingRepository rankingRepository;

    @Autowired
    BloggerTypeRepository bloggerTypeRepository;


    public void saveAll(List<Ranking> rankings){
        rankingRepository.bathSave(rankings);
    }

    public List<Ranking> getRankings(long bloggerType, int rankingType, int belong){
        return rankingRepository.findRankingsByBloggerTypeAndRankingTypeAndBelongOrderByScoreDesc(bloggerType,rankingType,belong);
    }

    public List<Ranking> getRankings(long bloggerType, int rankingType, int firstDate, int lastDate){
        return rankingRepository.findRankings(bloggerType,rankingType,firstDate,lastDate);
    }

    public List<BloggerType> getBloggerTypes(){
        return bloggerTypeRepository.getBloggerTypeByIsDisplay(true);
    }

}
